
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"
log using LSU_FundingContagion_2023.log, replace


**Describe variables***
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
describe


//////////////////////////////////////////////////////////
*** Results
/////////////////////////////////////////////////////////

**Figure 1
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

bysort bvid: egen min_year=min(year)
keep if year==min_year

keep own_sic other_sic ever_other_shock3p

gen aux=1
bysort own_sic other_sic: egen count_pairs=count(aux)

duplicates drop

gen size=1
replace size=2 if count_pairs>1 & count_pairs<6
replace size=3 if count_pairs>5


**Figure 1
 twoway (scatter own_sic other_sic [w=size], msize(small) msymbol(x) mcolor(green) mfcolor(none)) ///
 , ytitle("Own Firm SIC") xtitle("Other Firm SIC") ///
 title("SIC Pairwise Distribution") 
graph export Fig1.pdf, replace

 

***Figure 2: Histogram
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

histogram stake, bin(20) percent bcolor(gray) title("Frequency of stakes")
graph export Fig2.pdf, replace

***Figure 3
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

*By Own Shock
graph bar own_exshock other_exshock, over(own_sic1) bar(1, bcolor(gs4*.5)) bar(2, bcolor(gs4*1.5)) ///
title("Frequency of Other and Own Shocks by Own SIC code") legend(lab(1 "Own Shock") lab(2 "Other Shock")) ///
note(SIC code: 1 digit)
graph export Fig3.pdf, replace




**TABLE 1
***Summary statistics
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

tabstat Asset ag_w dg_w debt_is debt_ret debt_change bklev_w bank_rels destroying_rels empl roa1_w sale_asset_w own_Tob_Q_w tangibility_w stake stake_increase stake_decrease own_exshock other_exshock, statistics( mean p10 p25 p50 p75 p90 count ) columns(statistics) save
 mat tab2= r(StatTotal)'
frmttable using table1.doc, statmat(tab2) sdec(2,2,2,2,2,2,0) varlabels replace ctitle("","Mean", "P10" , "P25", "P50", "P75", "P90", "Total")




**Table 2
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

set more off
reghdfe ag_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig) replace
reghdfe dg_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig)
reghdfe dga_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig)
reghdfe bklev_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig)
reghdfe debt_i other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig)
reghdfe debt_r other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig)
reghdfe debt_change other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig)
**Panel B
set more off
reghdfe destroying_rels other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig) replace
reghdfe stake other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig) 
reghdfe stake_increase other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig)
reghdfe stake_decrease other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table2b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig)

***Table 3
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

**Asset growth
reghdfe ag_w other_exshock3p2 lag_assets if control_both==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Full control both) replace
reghdfe ag_w other_exshock3p2 lag_assets if control_partial==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Partial control in one or both) 
set more off 
reghdfe ag_w other_exshock3p2 lag_assets if control_no==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, No control in one or both) 
***Debt change
reghdfe dg_w other_exshock3p2 lag_assets if control_both==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Full control both) 
reghdfe dg_w other_exshock3p2 lag_assets if control_partial==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Partial control in one or both) 
set more off 
reghdfe dg_w other_exshock3p2 lag_assets if control_no==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, No control in one or both) 
***Debt change asset base
reghdfe dga_w other_exshock3p2 lag_assets if control_both==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Full control both) 
reghdfe dga_w other_exshock3p2 lag_assets if control_partial==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Partial control in one or both) 
set more off 
reghdfe dga_w other_exshock3p2 lag_assets if control_no==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, No control in one or both) 

***Book leverage 
reghdfe bklev_w other_exshock3p2 lag_assets if control_both==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Full control both) replace
reghdfe bklev_w other_exshock3p2 lag_assets if control_partial==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Partial control in one or both) 
set more off 
reghdfe bklev_w other_exshock3p2 lag_assets if control_no==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, No control in one or both) 
/* Net debt issuance */
reghdfe debt_change other_exshock3p2 lag_assets if control_both==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, No control in one or both) 
reghdfe debt_change other_exshock3p2 lag_assets if control_partial==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Full control both) 
set more off 
reghdfe debt_change other_exshock3p2 lag_assets if control_no==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, No control in one or both) 
 ***Bank rels
set more off 
reghdfe destroying_rels other_exshock3p2 lag_assets if control_both==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, No control in one or both) 
reghdfe destroying_rels other_exshock3p2 lag_assets if control_partial==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Full control both) 
set more off 
reghdfe destroying_rels other_exshock3p2 lag_assets if control_no==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table3b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, No control in one or both) 


***Table 4: Market-level financial constraints
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

set more off 
reghdfe ag_w other_exshock3p2 lag_assets if high_credit==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, High credit develop) replace
set more off 
reghdfe ag_w other_exshock3p2 lag_assets if high_credit==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Low credit develop) 
**** Debt change
 set more off 
reghdfe dg_w other_exshock3p2 lag_assets if high_credit==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, High credit develop) 
set more off 
reghdfe dg_w other_exshock3p2 lag_assets if high_credit==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Low credit develop) 
**** Debt change asset base
 set more off 
reghdfe dga_w other_exshock3p2 lag_assets if high_credit==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, High credit develop) 
set more off 
reghdfe dga_w other_exshock3p2 lag_assets if high_credit==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Low credit develop) 

***Panel B 
**Book leverage
 set more off 
reghdfe bklev_w other_exshock3p2 lag_assets if high_credit==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, High credit develop) replace
set more off 
reghdfe bklev_w other_exshock3p2 lag_assets if high_credit==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Low credit develop) 
 **Bet debt issuance
 set more off 
reghdfe debt_change other_exshock3p2 lag_assets if high_credit==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, High credit develop)
set more off 
reghdfe debt_change other_exshock3p2 lag_assets if high_credit==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Low credit develop) 
 **Banking rels 
 set more off 
reghdfe destroying_rels other_exshock3p2 lag_assets if high_credit==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, High credit develop)
set more off 
reghdfe destroying_rels other_exshock3p2 lag_assets if high_credit==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table4b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Low credit develop) 


****Table 5: Size split
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

***Panel A
set more off
reghdfe ag_w other_exshock3p2 lag_assets if small_own==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Small Own) replace
reghdfe ag_w other_exshock3p2 lag_assets if small_own==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Large Own)
reghdfe ag_w other_exshock3p2 lag_assets if small_own==1 & small_other==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Small Both)
reghdfe ag_w other_exshock3p2 lag_assets if small_own==0 & small_other==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5a, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Large Both)

***Panel B
reghdfe dg_w other_exshock3p2 lag_assets if small_own==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Small Own)
reghdfe dg_w other_exshock3p2 lag_assets if small_own==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Large Own)
reghdfe dg_w other_exshock3p2 lag_assets if small_own==1 & small_other==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Small Both)
reghdfe dg_w other_exshock3p2 lag_assets if small_own==0 & small_other==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5b, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Large Both)


***Panel C
set more off
reghdfe dga_w other_exshock3p2 lag_assets if small_own==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5c, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Small Own) replace
reghdfe dga_w other_exshock3p2 lag_assets if small_own==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5c, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Large Own)
reghdfe dga_w other_exshock3p2 lag_assets if small_own==1 & small_other==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5c, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Small Both)
reghdfe dga_w other_exshock3p2 lag_assets if small_own==0 & small_other==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5c, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Large Both)

***Panel D
reghdfe bklev_w other_exshock3p2 lag_assets if small_own==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5d, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Small Own) replace
reghdfe bklev_w other_exshock3p2 lag_assets if small_own==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5d, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Large Own)
reghdfe bklev_w other_exshock3p2 lag_assets if small_own==1 & small_other==1, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5d, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Small Both)
reghdfe bklev_w other_exshock3p2 lag_assets if small_own==0 & small_other==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table5d, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, Large Both)


***Table 6: Cross-pledgeability. CFs vs hard assets
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

**
reghdfe ag_w other_exshock3p2 shock_small_own shock_small_other shock_high_tang shock_high_roa lag_assets, a(id own_sic#year) cl(owner own_sic)
outreg2 using Table_6, keep(other_exshock3p2 shock_high_tang shock_high_roa) word bdec(3) r2  nocons label ///
 addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Size x shock controls, Yes)  replace
 
reghdfe  dg_w other_exshock3p2 shock_small_own shock_small_other shock_high_tang shock_high_roa lag_assets, a(id own_sic#year) cl(owner own_sic)
outreg2 using Table_6, keep(other_exshock3p2 shock_high_tang shock_high_roa) word bdec(3) r2  nocons label ///
 addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Size x shock controls, Yes) 
 
reghdfe  dga_w other_exshock3p2 shock_small_own shock_small_other shock_high_tang shock_high_roa lag_assets, a(id own_sic#year) cl(owner own_sic)
outreg2 using Table_6, keep(other_exshock3p2 shock_high_tang shock_high_roa) word bdec(3) r2  nocons label ///
 addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Size x shock controls, Yes) 

reghdfe bklev_w other_exshock3p2 shock_small_own shock_small_other shock_high_tang shock_high_roa lag_assets, a(id own_sic#year) cl(owner own_sic)
outreg2 using Table_6, keep(other_exshock3p2 shock_high_tang shock_high_roa) word bdec(3) r2  nocons label ///
 addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Size x shock controls, Yes) 
 
 
 
 
***Table 7: Finer margins of integration
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

**Excluding somewhat integrated industries
reghdfe ag_w other_exshock3p2 lag_assets if integration==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table7, sortvar(other_exshock3p2 lag_assets) word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Excl. 0%<Int. <1%, Yes, Excl. Same SIC2, No) replace
**Excluding somewhat related industries
reghdfe ag_w other_exshock3p2 lag_assets if integration==0 & same_sic2==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table7, sortvar(other_exshock3p2 lag_assets) word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Excl. 0%<Int. <1%, Yes, Excl. Same SIC2, Yes)
**Repeating for debt growth
**Excluding somewhat integrated industries
reghdfe dg_w other_exshock3p2 lag_assets if integration==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table7, sortvar(other_exshock3p2 lag_assets) word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Excl. 0%<Int. <1%, Yes, Excl. Same SIC2, No) 
**Excluding somewhat related industries
reghdfe dg_w other_exshock3p2 lag_assets if integration==0 & same_sic2==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table7, sortvar(other_exshock3p2 lag_assets) word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Excl. 0%<Int. <1%, Yes, Excl. Same SIC2, Yes)
**Repeating for debt growth asset base
reghdfe dga_w other_exshock3p2 lag_assets if integration==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table7, sortvar(other_exshock3p2 lag_assets) word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Excl. 0%<Int. <1%, Yes, Excl. Same SIC2, No) 
**Excluding somewhat related industries
reghdfe dga_w other_exshock3p2 lag_assets if integration==0 & same_sic2==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table7, sortvar(other_exshock3p2 lag_assets) word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Excl. 0%<Int. <1%, Yes, Excl. Same SIC2, Yes)
**Repeating for leverage
reghdfe bklev_w other_exshock3p2 lag_assets if integration==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table7, sortvar(other_exshock3p2 lag_assets) word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Excl. 0%<Int. <1%, Yes, Excl. Same SIC2, No) 
**Excluding somewhat related industries
reghdfe bklev_w other_exshock3p2 lag_assets if integration==0 & same_sic2==0, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table7, sortvar(other_exshock3p2 lag_assets) word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Excl. 0%<Int. <1%, Yes, Excl. Same SIC2, Yes)


***Table 8: Matched sample***
**Panel A: Matched control firms
***First match
**Columns 1-4
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use Nn_stake_size_final
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results" 
xtset panel_id year, yearly
label var own_sic "Own Firm SIC"
keep ag_w dg_w dga_w bklev_w lag_assets treated year min_year panel_id own_sic year m_other_exshock3p2

reghdfe ag_w  m_other_exshock3p2 lag_assets if treated==0 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo1,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Control firms, Matching, Nearest neighbor, Matching by, "Stake, size, industry, year, and country") replace 
reghdfe dg_w  m_other_exshock3p2 lag_assets if treated==0 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo1,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Control firms, Matching, Nearest neighbor, Matching by, "Stake, size, industry, year, and country")
reghdfe dga_w  m_other_exshock3p2 lag_assets if treated==0 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo1,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Control firms, Matching, Nearest neighbor, Matching by, "Stake, size, industry, year, and country")
reghdfe bklev_w  m_other_exshock3p2 lag_assets if treated==0 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo1,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Control firms, Matching, Nearest neighbor, Matching by, "Stake, size, industry, year, and country")

***Second match
**Columns 5-8
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use Nn_stake_age_size_lev_final
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results" 
xtset panel_id year, yearly
label var own_sic "Own Firm SIC"
keep ag_w dg_w dga_w bklev_w lag_assets treated year min_year panel_id own_sic year m_other_exshock3p2

reghdfe ag_w  m_other_exshock3p2 lag_assets if treated==0 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo2,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Control firms, Matching, Nearest neighbor, Matching by, "Stake, size, age, leverage, industry, year, and country") replace 
reghdfe dg_w  m_other_exshock3p2 lag_assets if treated==0 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo2,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Control firms, Matching, Nearest neighbor, Matching by, "Stake, size, age, leverage, industry, year, and country")
reghdfe dga_w  m_other_exshock3p2 lag_assets if treated==0 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo2,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Control firms, Matching, Nearest neighbor, Matching by, "Stake, size, age, leverage, industry, year, and country")
reghdfe bklev_w  m_other_exshock3p2 lag_assets if treated==0 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo2,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Control firms, Matching, Nearest neighbor, Matching by, "Stake, size, age, leverage, industry, year, and country")
 
 
****Panel B:  Matched treated firms
***Treated: First match
**Columns 1-4
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use Nn_stake_size_final
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results" 
xtset panel_id year, yearly
label var own_sic "Own Firm SIC"
keep ag_w dg_w dga_w bklev_w lag_assets treated year min_year panel_id own_sic year m_other_exshock3p2

reghdfe ag_w  m_other_exshock3p2 lag_assets if treated==1 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo3,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Treated firms, Matching, Nearest neighbor, Matching by, "Stake, size, industry, year, and country") replace 
reghdfe dg_w  m_other_exshock3p2 lag_assets if treated==1 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo3,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Treated firms, Matching, Nearest neighbor, Matching by, "Stake, size, industry, year, and country")
reghdfe dga_w  m_other_exshock3p2 lag_assets if treated==1 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo3,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Treated firms, Matching, Nearest neighbor, Matching by, "Stake, size, industry, year, and country")
reghdfe bklev_w  m_other_exshock3p2 lag_assets if treated==1 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo3,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Treated firms, Matching, Nearest neighbor, Matching by, "Stake, size, industry, year, and country")

******Treated: Second match
**Columns 5-8
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use Nn_stake_age_size_lev_final
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results" 
xtset panel_id year, yearly
label var own_sic "Own Firm SIC"
keep ag_w dg_w dga_w bklev_w lag_assets treated year min_year panel_id own_sic year m_other_exshock3p2

reghdfe ag_w  m_other_exshock3p2 lag_assets if treated==1 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo4,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Treated firms, Matching, Nearest neighbor, Matching by, "Stake, size, age, leverage, industry, year, and country") replace 
reghdfe dg_w  m_other_exshock3p2 lag_assets if treated==1 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo4,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Treated firms, Matching, Nearest neighbor, Matching by, "Stake, size, age, leverage, industry, year, and country")
reghdfe dga_w  m_other_exshock3p2 lag_assets if treated==1 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo4,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Treated firms, Matching, Nearest neighbor, Matching by, "Stake, size, age, leverage, industry, year, and country")
reghdfe bklev_w  m_other_exshock3p2 lag_assets if treated==1 & year>=min_year, a(panel_id own_sic#year) cl(panel_id) 
outreg2 using Table_placebo4,word bdec(3) r2  nocons label addtext(Firm FE, Yes,  Industry-year FE, 3-dig, Sample, Treated firms, Matching, Nearest neighbor, Matching by, "Stake, size, age, leverage, industry, year, and country")
  

 
***Table 9: Current vs non-current and other outcomes
***
clear all
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final"
use main_data_RCFS_July_2023
cd "C:\Users\sertsios\Dropbox\Exogenous Shocks\Stakes\RCFS\Final\Results"

set more off
reghdfe fag_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All) replace
reghdfe nfag_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All) 
reghdfe cashg_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All) 
reghdfe othercuasg2_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All) 
reghdfe ncdga_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All) 
reghdfe cdga_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All) 
**Other outcomes
reghdfe log_empl other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All) 
reghdfe roa1_w other_exshock3p2 lag_assets, a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All) 
reghdfe oppl_w other_exshock3p2 lag_assets if roa1_w!=., a(id own_sic#year) cl(owner own_sic) 
outreg2 using Table9, word bdec(3) r2 nocons label addtext(Firm FE, Yes, Industry-year FE, 3-dig, Sample, All)


log close
graphlog using LSU_FundingContagion_2023.log, lspacing(1) replace
